/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bgu.ppm.sim.impl.mas.agents;

import bgu.ppm.sim.api.mas.Mailer;
import bgu.ppm.sim.api.mas.Message;

/**
 *
 * @author User
 */
public class SendMediator {

    private Message message = null;
    private Mailer mailer;
    private int ownerID;

    public SendMediator(Mailer mailer, int ownerID) {
        this.mailer = mailer;
        this.ownerID = ownerID;
    }

    /*package*/ SendMediator setMessage(Message message) {
        this.message = message;
        return this;
    }

    public void to(int recepient) {
        mailer.send(message, recepient);
    }

    public void toNextAgent() {
        to(ownerID + 1);
    }

    public void toPreviousAgent() {
        to(ownerID - 1);
    }

    public void to(int... recepients) {
        for (int r : recepients) {
            to(r);
        }
    }
}
